﻿@using System.Globalization
@using AbpZeroTemplate.Editions
@using AbpZeroTemplate.MultiTenancy.Payments;
@model AbpZeroTemplate.Web.Models.Payment.PaymentViewModel

@{
    Layout = "~/Views/Account/_Layout.cshtml";
    ViewBag.DisableTenantChange = true;
}

@section Scripts
{
    <script abp-src="/view-resources/Views/Payment/Payment.js" asp-append-version="true"></script>
}

@section Styles
{
    <link abp-href="/view-resources/Views/Payment/Payment.css" rel="stylesheet" type="text/css" />
}
<div class="m-login__signin">
    <div class="m-login__head">
        <h3 class="m-login__title">
            @L("PaymentInfo")
        </h3>
    </div>
    <form class="register-form" method="post" asp-action="@Model.GetFormAction()" asp-controller="@Model.GetFormPostController()" asp-area="@Model.GetFormArea()" id="formPaymentResult">
        <input type="hidden" name="EditionId" value="@Model.Edition.Id" />
        <input type="hidden" name="Gateway" value="" />
        <input type="hidden" name="EditionPaymentType" value="@Model.EditionPaymentType" />
        <input type="hidden" name="SubscriptionStartType" value="@Model.SubscriptionStartType" />

        @if (Model.EditionPaymentType == EditionPaymentType.Extend || Model.EditionPaymentType == EditionPaymentType.Upgrade)
        {
            <div class="hint text-center block">(@L(Model.EditionPaymentType + "_Edition_Description", Model.Edition.DisplayName))</div>
        }
        else
        {
            <div class="hint text-center">(@Model.Edition.DisplayName @L("Edition"))</div>
        }

        @if (ViewBag.ErrorMessage != null)
        {
            <div class="alert alert-danger">
                <i class="fa fa-warning"></i> @ViewBag.ErrorMessage
            </div>
        }

        @if (Model.IsUpgrading())
        {
            <hr class="border-green" />
            <div class="form-actions">
                <div class="form-group row">
                    <label class="col-sm-8 control-label">@L("Total")</label>
                    <div class="col-sm-4 text-right">
                        <p class="form-control-static text-bold" id="totalPrice">
                            $@Model.AdditionalPrice.Value.ToString("N2")
                        </p>
                    </div>
                </div>
            </div>
        }
        else
        {
            if (Model.Edition.MonthlyPrice.HasValue)
            {
                <div class="form-group">
                    <label class="m-radio m-radio-outline margin-bottom-0">
                        <input class="form-control" type="radio" name="PaymentPeriodType"
                               data-day-count="@((int)PaymentPeriodType.Monthly)"
                               data-payment-period-type-amount="@(Model.Edition.MonthlyPrice.Value.ToString("0.00", CultureInfo.InvariantCulture))"
                               value="@PaymentPeriodType.Monthly" />@L("MonthlyPrice"): $@Model.Edition.MonthlyPrice.Value.ToString("N2")
                            <span></span>
                        </label>
                    </div>
            }

            if (Model.Edition.AnnualPrice.HasValue)
            {
                <div class="form-group">
                    <label class="m-radio m-radio-outline margin-bottom-0">
                        <input class="form-control" type="radio" name="PaymentPeriodType"
                               data-day-count="@((int)PaymentPeriodType.Annual)"
                               data-payment-period-type-amount="@(Model.Edition.AnnualPrice.Value.ToString("0.00", CultureInfo.InvariantCulture))"
                               value="@PaymentPeriodType.Annual" />@L("AnnualPrice"): $@Model.Edition.AnnualPrice.Value.ToString("N2")
                            <span></span>
                        </label>
                    </div>
            }
        }

        @foreach (var paymentGatewayAdditionalData in Model.Edition.AdditionalData)
        {
            @Html.Partial("_" + paymentGatewayAdditionalData.Key + ".cshtml", Model)
        }

    </form>
</div>